package com.pharmacy.pharmacy.controller;


import com.pharmacy.pharmacy.domain.Category;
import com.pharmacy.pharmacy.service.ICategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@CrossOrigin
/**
 * 【】Controller
 * 
 * @author 
 * @date 2025-05-08
 */
@RestController
@RequestMapping("/system/category")
public class CategoryController 
{
    @Autowired
    private ICategoryService categoryService;

    /**
     * 查询【】列表
     */
    @GetMapping("/list")
    public List<Category> list(Category category)
    {

        return categoryService.selectCategoryList(category);
    }

   

    /**
     * 获取【】详细信息
     */
    @GetMapping(value = "/{id}")
    public Category getInfo(@PathVariable("id") Long id)
    {
        return categoryService.selectCategoryById(id);
    }

    /**
     * 新增【】
     */
    @PostMapping
    public int add(@RequestBody Category category)
    {
        return categoryService.insertCategory(category);
    }

    /**
     * 修改【】
     */
    @PutMapping
    public int edit(@RequestBody Category category)
    {
        return categoryService.updateCategory(category);
    }

    /**
     * 删除【】
     */
	@DeleteMapping("/{ids}")
    public int remove(@PathVariable Long[] ids)
    {
        return categoryService.deleteCategoryByIds(ids);
    }
}
